$(function () {
    $.post(linkGetListData, {
        id: id
    }, function (text) {
        let data = JSON.parse(text);
        $("#name").val(data.name);
        $("#times").val(data.time);
        $("#name2").val(data.type);
        $("textarea.name3").val(data.content);
        console.log(data);
    });
    $("#del").click(function () {
        if (confirm("是否删除？")){
            $.post(linkDeleteList, {
                id: id
            }, function (text) {
                alert(text);
                location.href = linkIndex;
            });
        }
    });
    $("#save").click(function () {
        let name = $("#name").val();
        let content = $("textarea.name3").val();
        let time = $("input#times").val().toString().replace("T", " ");
        let type = $("#name2").val();
        if (content) {
            $.post(linkUpdateList, {
                id:id,
                name: name,
                time: time,
                type: type,
                content: content
            }, function (text) {
                alert(text);
                location.href = linkIndex;
            });
        } else {
            alert("清单内容不能为空");
        }
    });
});